<template>
  <div class="login-container">
    <!-- 左边 -->
    <div class="logo" />
    <!-- 右边 -->
    <div class="form">
      <h1>智慧园区-登录</h1>
      <el-card shadow="never" class="login-card">
        <!--登录表单-->
        <el-form ref="loginRef" :model="loginForm" :rules="loginRules">
          <el-form-item>
            <p class="margintips">账号</p>
            <el-input v-model="loginForm.username" placeholder="请输入手机号" />
          </el-form-item>
          <el-form-item>
            <p class="margintips">密码</p>
            <el-input v-model="loginForm.password" show-password type="password" placeholder="请输入密码" />
          </el-form-item>
          <el-form-item prop="password">
            <div>
              <p class="margintips">模型uuid:</p>
              <el-input v-model="loginForm.uuid" show-password type="password" placeholder="请输入模型uuid" />
            </div>

          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="loginForm.isAgree">记住我</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-button style="width:300px;border-radius: 4px;height: 33px;" type="primary" @click="login">登录</el-button>
          </el-form-item>
          <el-form-item>
            <p class="tips">仅用于IT培训教学使用，为保障您的个人信息安全，请勿向平台录入任何个人敏感信息(如手机号、身份证号等)!</p>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>
</template>

<script>
import store from '@/store'
export default {
  name: 'Login',
  data() {
    return {
      userInfo: { use: 'demo', pass: 'Hmzs%001' },
      loginForm: {
        username: store.getters.userInfo ? store.getters.userInfo.username : '',
        password: store.getters.userInfo ? store.getters.userInfo.password : '',
        uuid: process.env.NODE_ENV === 'development' ? '66ea8d2a-7416-4be5-ba7e-c030cf88b3f3' : '',
        isAgree: store.getters.userInfo ? store.getters.userInfo.isAgree : false
      },
      loginRules: {
        mobile: [
          { required: true, message: '请输入账号', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
    if (store.getters.userInfo) {
      this.userInfo = store.getters.userInfo
    }
  },
  methods: {
    async login() {
      const { username, password, isAgree } = this.loginForm
      this.$store.dispatch('user/login', { username, password, isAgree })
    }
  }
}
</script>

<style lang="scss" scoped>
.login-container {
  display: flex;
  align-items: stretch;
  height: 100vh;
  .logo {
    flex: 3;
    background: rgb(8, 26, 81) url(../../assets/common/login_back.png) no-repeat center / cover;
    border-top-right-radius: 60px;
  }
  .form {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 105px;
    padding-right: 105px;
    padding-top: 190px;

    .el-card {
      border: none;
      padding: 0;
    }

    h1 {
      padding-left: 20px;
      font-size: 26px;
      font-weight: 500;

    }

    .margintips{
      margin-bottom: -8px;
      font-size:12 ;
      color: #8b929d;
    }
    .tips{
      font-size: 11;
      color:red;
      line-height: 18px;
    }

    .el-input {
      width: 300px;
      height: 30px;
      .el-input__inner {
        background: #f4f5fb;
      }
    }

     .el-checkbox {
      color: #606266;
    }
  }
}
</style>
